<!DOCTYPE html>
<html>

<head>
    <title>投资记录</title>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1,user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/reset.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/flex.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/dropload.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/accounts-child.css">
    <script type="text/javascript" src="/resource/web/js/flexible.js"></script>
    <script type="text/javascript" src="/resource/web/js/jquery-1.11.1.min.js"></script>
</head>

<body>
<div class="mod-tit">
    <div class="title">
        <p>投资记录</p>
        <a href="/Web/user_accounts"><img class="back" src="/resource/web/img/newhead/path_7_copy.png"></a>
    </div>
</div>
    <div class="mod-inves content">
        <div class="mod-inv lists" ></div>
    </div>
    <!-- 无投资记录显示 -->
    <div class="mod-not3">
        <p><img src="/resource/web/img/account/no_msg.png"></p>
    </div>
<script src="/resource/web/js/dropload.min.js"></script>
<script type="text/javascript">
    function getLocalTime(nS) {
        var dateStr=new Date(parseInt(nS) * 1000).toLocaleDateString();
        dateStr=dateStr.replace(/年|月/g, "/").replace(/日/g,"");
        var month = (new Date(dateStr)).getMonth() + 1;
        var year = (new Date(dateStr)).getFullYear();
        var date = (new Date(dateStr)).getDate();
        if (month < 10) {
            month = '0' + month;
        }
        if (date < 10) {
            date = '0' + date;
        }
        return year+"-"+month+"-"+date;
    }

    $(function(){
        // 页数
        var page = 0;
        // 每页展示5个
        //var size = 10;
        // dropload
        $('.content').dropload({
            scrollArea : window,
            loadDownFn : function(me){
                page++;
                var result = '';
                $.ajax({
                    type: 'POST',
                    processData: false,
                    url: '/Web/invest_record_data?page='+page,
                    dataType: 'json',
                    success: function(data){
                        var arrLen = data.length;
                        var arrlist = data;
                        console.log(arrLen);
                        console.log(arrlist);
                        if(arrLen > 0){
                            $(".mod-not3").hide();

                            for(var i=0; i<arrLen; i++){
                                console.log( arrlist[i].repaying_time );
                                if ( arrlist[i].repaying_time != "融满起息" ) {
                                    if( arrlist[i].rate== 0 ){
                                        result += '<a class="item opacity" href="/Web/ft/'+arrlist[i].auto_id+'.html">'
                                                +'<div class="inves">'
                                                + '<p class="inv-tit">'+arrlist[i].title+'<span class="inv-typ1">'+arrlist[i].item_status+'</span>'
                                                +'</p>'
                                                +'<ul class="inv-con tcf-flex tcf-justify-justify"><li>'
                                                +'<p>投资金额<span>'+arrlist[i].amount+'元</span></p><p>预计收益<span>'+arrlist[i].expect_earnings+'元</span></p>'
                                                +'</li> <li> <p>投资日期<span>'+getLocalTime(arrlist[i].add_time)+'</span></p><p>还款日期<span>'+getLocalTime(arrlist[i].repaying_time)+'</span></p>'
                                                +'</li></ul></div></a>'

                                    }else{
                                        result += '<a class="item opacity" href="/Web/ft/'+arrlist[i].auto_id+'.html">'
                                                +'<div class="inves">'
                                                + '<p class="inv-tit">'+arrlist[i].title+'<span class="inv-typ1">'+arrlist[i].item_status+'</span>'
                                                +'<span class="inv-typ2"><span>已加息'+arrlist[i].rate+'%</span></p>'
                                                +'<ul class="inv-con tcf-flex tcf-justify-justify"><li>'
                                                +'<p>投资金额<span>'+arrlist[i].amount+'元</span></p><p>预计收益<span>'+arrlist[i].expect_earnings+'元</span></p>'
                                                +'</li> <li> <p>投资日期<span>'+getLocalTime(arrlist[i].add_time)+'</span></p><p>还款日期<span>'+getLocalTime(arrlist[i].repaying_time)+'</span></p>'
                                                +'</li></ul></div></a>'
                                    }
                                }else {
                                    if( arrlist[i].rate== 0 ){
                                        result += '<a class="item opacity" href="/Web/ft/'+arrlist[i].auto_id+'.html">'
                                                +'<div class="inves">'
                                                + '<p class="inv-tit">'+arrlist[i].title+'<span class="inv-typ1">'+arrlist[i].item_status+'</span>'
                                                +'</p>'
                                                +'<ul class="inv-con tcf-flex tcf-justify-justify"><li>'
                                                +'<p>投资金额<span>'+arrlist[i].amount+'元</span></p><p>预计收益<span>'+arrlist[i].expect_earnings+'元</span></p>'
                                                +'</li> <li> <p>投资日期<span>'+getLocalTime(arrlist[i].add_time)+'</span></p><p>还款日期<span>融满起息</span></p>'
                                                +'</li></ul></div></a>'

                                    }else{
                                        result += '<a class="item opacity" href="/Web/ft/'+arrlist[i].auto_id+'.html">'
                                                +'<div class="inves">'
                                                + '<p class="inv-tit">'+arrlist[i].title+'<span class="inv-typ1">'+arrlist[i].item_status+'</span>'
                                                +'<span class="inv-typ2"><span>已加息'+arrlist[i].rate+'%</span></p>'
                                                +'<ul class="inv-con tcf-flex tcf-justify-justify"><li>'
                                                +'<p>投资金额<span>'+arrlist[i].amount+'元</span></p><p>预计收益<span>'+arrlist[i].expect_earnings+'元</span></p>'
                                                +'</li> <li> <p>投资日期<span>'+getLocalTime(arrlist[i].add_time)+'</span></p><p>还款日期<span>融满起息</span></p>'
                                                +'</li></ul></div></a>'
                                    }
                                }
                            }
                            // 如果没有数据
                        }else{
                            // 锁定
                            me.lock();
                            // 无数据
                            me.noData();


                        }
                        $('.lists').append(result);
                        me.resetload();
                        // 为了测试，延迟1秒加载
                        /*setTimeout(function(){
                         // 插入数据到页面，放到最后面
                         $('.lists').append(result);
                         // 每次数据插入，必须重置
                         me.resetload();
                         },1000);*/
                    },
                    error: function(xhr, type){
                        console.log('Ajax error!');
                        // 即使加载出错，也得重置
                        me.resetload();
                    }
                });
            }
        });
    });
</script>
</body>

</html>
